import {Point} from './point.js'
import {Circle} from './Circle.js'

let yuanxin = new Point(1,1)
let circle = new Circle(yuanxin,1)
let count = 0//有多少个点在圆里
for (let i = 0; i < 100000; i++)
    {
        let x_tmp = Math.random()*2
        let y_tmp = Math.random()*2
        let point_tmp = new Point(x_tmp,y_tmp)
        if(circle.isPointInCircle(point_tmp))
            {
                count++
            }
    }
console.log(count*4/100000);
//π的计算方式是设定一个正方形的内接圆，并在正方形内随机抛点
//之后算出来有多少点抛在了圆内，抛的点越多，越精确
// 公式：π/正方形面积 = 在圆内的点/抛的总点数